package com.imrookie.wrap;

import java.lang.reflect.Field;

/**
 * 字段包装类
 * @author wangjiyu@imdada.cn
 * @create 2018/12/13
 */
public class FieldWrap {
    private String fieldName;//字段名
    private Field field;//属性对象引用
    private ClassWrap classWrap;//类型
    private GenericWrap genericWrap;//字段泛型信息

    public FieldWrap() {

    }

    public FieldWrap(Field field) {
        fieldName = field.getName();
        this.field = field;
        classWrap = ClassWrap.getInstance(field.getType());
        this.genericWrap = new GenericWrap(field.getGenericType());
    }

    @Override
    public String toString() {
        return "FieldWrap{" +
                "fieldName='" + fieldName + '\'' +
                ", classWrap=" + classWrap.getClassName() +
                '}';
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public Field getField() {
        return field;
    }

    public void setField(Field field) {
        this.field = field;
    }

    public ClassWrap getClassWrap() {
        return classWrap;
    }

    public void setClassWrap(ClassWrap classWrap) {
        this.classWrap = classWrap;
    }

    public GenericWrap getGenericWrap() {
        return genericWrap;
    }

    public void setGenericWrap(GenericWrap genericWrap) {
        this.genericWrap = genericWrap;
    }
}
